home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / DBL Pascal Library / DefProcs / ICON Cntl / IconTest.p < prev    next >
Text File  |  1992-10-02  |  2KB  |  70 lines

  1. program IconTest;
  2.  
  3.     const
  4.         dialogID = 128;
  5.         firstIconButton = 2;
  6.         lastIconButton = 4;
  7.         disableCheckbox = 5;
  8.         hideCheckbox = 6;
  9.  
  10.     var
  11.         theDialog: DialogPtr;
  12.         itemHit: Integer;
  13.         i: Integer;
  14.         evt: EventRecord;
  15.  
  16.     function GetControlHandle (item: Integer): ControlHandle;
  17.         var
  18.             kind: Integer;
  19.             h: Handle;
  20.             r: Rect;
  21.     begin
  22.         GetDItem(theDialog, item, kind, h, r);
  23.         if BAND(kind, $FC) = ctrlItem then
  24.             GetControlHandle := ControlHandle(h)
  25.         else
  26.             GetControlHandle := nil;
  27.     end;
  28.  
  29. begin
  30.     theDialog := GetNewDialog(dialogID, nil, POINTER(-1));
  31.     SetPort(theDialog);
  32.     TextFont(geneva);    {Try different fonts and sizes to see how useWFont variant works…}
  33.     TextSize(9);
  34.     ShowWindow(theDialog);
  35.     for i := 1 to 3 do    {Have to do this to synchronize TE items to the window font!}
  36.         if EventAvail(everyEvent, evt) then
  37.             ;
  38.     with DialogPeek(theDialog)^.textH^^ do
  39.         begin
  40.             txFont := theDialog^.txFont;
  41.             txSize := theDialog^.txSize;
  42.         end;
  43.     InitCursor;
  44.     repeat
  45.         ModalDialog(nil, itemHit);
  46.  
  47.         if ItemHit = firstIconButton then
  48.             SysBeep(5);
  49.  
  50.         if ItemHit = disableCheckbox then
  51.             begin
  52.                 SetCtlValue(GetControlHandle(disableCheckbox), 1 - GetCtlValue(GetControlHandle(disableCheckbox)));
  53.                 if GetCtlValue(GetControlHandle(disableCheckbox)) = 0 then
  54.                     HiliteControl(GetControlHandle(lastIconButton), 0)
  55.                 else
  56.                     HiliteControl(GetControlHandle(lastIconButton), 255);
  57.             end;
  58.  
  59.         if itemHit = hideCheckbox then
  60.             begin
  61.                 SetCtlValue(GetControlHandle(hideCheckbox), 1 - GetCtlValue(GetControlHandle(hideCheckbox)));
  62.                 if GetCtlValue(GetControlHandle(hideCheckbox)) = 0 then
  63.                     ShowControl(GetControlHandle(lastIconButton))
  64.                 else
  65.                     HideControl(GetControlHandle(lastIconButton));
  66.             end;
  67.  
  68.     until ItemHit = OK;
  69.     DisposDialog(theDialog);
  70. end.